import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const username = ref('')
  const avatar = ref('')

  // 从 localStorage 或 sessionStorage 获取用户信息
  const initialize = () => {
    const userInfo = JSON.parse(localStorage.getItem('user_info') || '{}')
    username.value = userInfo.username || ''
    avatar.value = userInfo.avatar || ''
  }

  return {
    username,
    avatar,
    initialize
  }
}) 